package com.log.controller;

import com.log.common.vo.ResultVo;
import com.log.pojo.LogDepartment;
import com.log.service.LogDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/department")
@Api(tags = "部门管理")
public class LogDepartmentController {
    @Autowired
    private LogDepartmentService logDepartmentService;
    @ApiOperation("通过id查询")
    @GetMapping("/getdeptbyid")
    //通过id查询
    public ResultVo getdeptid(int id) {

        return logDepartmentService.getLoglogDepartmentById(id);
    }
    @ApiOperation("通过id删除")
    //通过id删除
    @GetMapping("/deletebyid")
    public ResultVo delbyid(int id){

        return logDepartmentService.deleteLogDepartmentById(id);
    }
    @ApiOperation("添加部门")
    //添加部门
    @PostMapping("/insertdepartment")
    public ResultVo insertdept(@RequestBody LogDepartment logDepartment){
        return logDepartmentService.insertLogDepartment(logDepartment);
    }
    @ApiOperation("修改部门信息")
    //修改部门信息
    @PutMapping("/updatedept")
    public ResultVo updatedept(@RequestBody LogDepartment logDepartment){
        return logDepartmentService.updateLogDepartment(logDepartment);
    }
    @ApiOperation("分页查询")
    @GetMapping("/selectdepartmentbypage")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(dataType = "int",name = "pageNum",value = "当前的页数",required = true),
                    @ApiImplicitParam(dataType = "int",name = "limit",value = "每页查询的页数",required = true)
            }
    )
    public ResultVo selectLogDepartmentListByPage(int pageNum,int limit){
        return logDepartmentService.selectLogDepartmentListByPage(pageNum,limit);
    }


    @ApiOperation("查询全部")
    @GetMapping("/selectAll")
    public ResultVo selectLogDepartmentList(){
        return logDepartmentService.selectLogDepartmentList();
    }

}
